<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Jsaas 登录</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
#@resources()
<style type="text/css">
.login-container {
	padding-top: 50px;
	width: 500px;
}

.login-container .btns {
	text-align: right;
}

.login-container .login-title {
	font-weight: bold;
}

#txtcaptcha {
	width: calc(100% - 113px);
	display: inline-block;
}

#imgcaptcha {
	cursor: pointer;
}
</style>
</head>
<body>
	<div class="layui-container login-container">
		<fieldset class="layui-elem-field">
			<legend class="login-title">登录</legend>
			<div class="layui-field-box">
				<form class="layui-form layui-form-pane" action="">
					<div class="layui-form-item">
						<label class="layui-form-label">用户名</label>
						<div class="layui-input-block">
							<input type="text" name="account" autocomplete="off"
								placeholder="请输入用户名" value="admin" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">密码</label>
						<div class="layui-input-block">
							<input type="password" name="password" lay-verify="required"
								placeholder="请输入密码" value="123456" autocomplete="off"
								class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">验证码</label>
						<div class="layui-input-block">
							<input type="text" name="captcha" id="txtcaptcha"
								autocomplete="off" placeholder="请输入验证码" class="layui-input">
							<img id="imgcaptcha" alt="点击刷新验证码" title="点击刷新验证码"
								src="/login/getCaptcha">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">记住账号</label>
						<div class="layui-input-block">
							<input type="checkbox" name="close" lay-skin="switch"
								lay-text="ON|OFF">
							<div class="layui-unselect layui-form-switch layui-form-onswitch"
								lay-skin="_switch">
								<em>ON</em><i></i>
							</div>
						</div>
					</div>

					<div class="btns">
						<input class="layui-btn layui-btn-warm layui-btn-radius"
							type="button" value="注册"> <input id="btnlogin"
							class="layui-btn layui-btn-radius" type="button" value="登录">
					</div>

				</form>
			</div>
		</fieldset>

	</div>

	<script>
		//JavaScript代码区域
		layui.use([ 'form', 'layedit', 'laydate' ], function() {
			if (window != top) 
				top.location.href = location.href; 
			//登录
			$("#btnlogin").click(function() {
				var postdata = $("form").serialize();
				$.post("/login/dologin?" + postdata, {}, function(ret) {
					if (ret.state == "ok") {
						location.href = ctx + '/';
					} else {
						$("#txtcaptcha").val("");
						$("#imgcaptcha").click();
						alert(ret.msg);
					}
				});
			});
			
			$("#imgcaptcha").click(function(){
				$(this).attr("src", "/login/getCaptcha?t" + Math.random());
			});

		});
	</script>
</body>
</html>